package learningThread.api.stopApi;

public class MyThread1 extends Thread{

    @Override
    public void run() {

        try {
            for (int i = 0; i < 500000; i++) {
                if (this.isInterrupted()) {
                    System.out.println("已经停止了，即将退出");
                    throw new InterruptedException();
                }
                System.out.println("i="+(i+1));
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
            System.out.println("MyThread1 run方法内catch住了");
        }

        System.out.println("MyThread1 end");
    }
}
